#include <iostream>
#include <math.h>

using namespace std;

int T=1;
int K=10;
int t;
string KQ[10];

///ham tach so nguyen abcd thanh mang I[] ma I[1]=a; I[2]=b; I[3]=c; I[4] = d;
int I[100];

void extract2Arr(int n, int k){///tach so nguyen n co k chu so thanh mang k pt
    int K=k;
    while(n!=0){
        I[k]=n%10;
        n=n/10;
        k--;
    }

    //for(int i=1;i<=K;i++)
      //  cout<<I[i]<<" ";
}


///ham dem so lan xuat hien cua chu so x trong n
int countApp(int x, int n){
    int count =0;
    while(n!=0){
        if(n%10==x)
            count++;
        n=n/10;
    }
    return count;
}



/// x : 0->9
char toChar(int x){
    return x+48;
}

///ham chuyen so double n thanh string
string toString(long n){
    string res="";
    while(n!=0){
        res.insert(0,1,toChar(n%10));
        n=n/10;
    }
    return res;
}



void listCoolNum(int K){
    int found=0;
    int count=0;   ///so luong so cool tim thay
    int add=10;
    if(K>5)
        add=1000;
    for(double i=pow(10,K-1); i<pow(10,K); i +=add){

        found=1;
        extract2Arr(i,K);

        for(int j=1;j<=K;j++)
            if(I[j]!=countApp(j-1,i)){
                found=0;
                break;
            }

        if(found==1){
            count++;
            if (count==1)
                KQ[t] =toString(i);
            else
                KQ[t] += " "+toString(i);
        }

            //cout<<endl<<toString(i);
    }

    ///neu khong tim thay so cool nao
    if(count==0)
        KQ[t]="-1";

}
int main()
{
    //cin>>T;
    t=0;
    while(t<T){
      //  cin>>K;
        listCoolNum(11);
        t++;
    }

    t=0;
    while(t<T)
        cout<<endl<<KQ[t++];

    return 0;
}
